package com.dragon.pagingsample;

import androidx.annotation.IntDef;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


/**
 * 优化枚举
 * 一般枚举使用内存比较大
 */
public class SHAPE {
    private static final int RECTANGLE = 0;
    private static final int TRIANGLE = 1;
    private static final int SQUARE = 1 << 1;
    private static final int CIRCLE = 3;

    @Documented
    @IntDef(flag = true,value = {RECTANGLE,TRIANGLE,SQUARE,CIRCLE})
    @Target({ElementType.PARAMETER,ElementType.FIELD,ElementType.METHOD})
    @Retention(RetentionPolicy.SOURCE)
    public @interface Model{


    }

    private @Model int value = RECTANGLE;
    public void setShape(@Model int value){
        this.value = value;
    }

    @Model
    public int getShape(){
        return this.value;
    }
}
